<template>
	<view class="wrap">
		<view class="search">
			<u-search v-model="keywords" @custom="search" @search="search"></u-search>
		</view>
		<scroll-view class="scroll-list" scroll-y="true" @scrolltolower="loadMore">
			<u-cell-group v-for="(item, index) in list" :key="item.id" :index="index" >
					<u-cell-item :arrow="true" @click="navTo('smth?id='+item.id+'&ccode='+item.ccode+'&cusname='+item.ccusname)">
						<view slot="label" class="u-font-lg">
							<view class="padding-bottom-sm text-bold"><text><text class="text-bold">{{index+1}}、</text>退库单号：{{item.ccode}}</text></view>
							<view class="padding-bottom-sm"><text >客户名称：{{item.ccusname}}</text></view>
						</view>
					</u-cell-item>
					<u-line color="blue" />
			</u-cell-group>
			<view class="loadmore" @click="loadMore">
				<u-loadmore :status="loadStatus"></u-loadmore>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				keywords:'',
				query: {
					data:'',
					pageNo: 1,
					pageSize: 10,
					bredvouch:0
				},
				list:[],
				loadStatus: 'loadmore',
			}
		},
		onShow() {
			this.search();
		},
		onLoad() {
			
		},
		onPullDownRefresh() {
			this.list=[];
			this.loadList();
			setTimeout(()=>{
				uni.stopPullDownRefresh();
			},1000)
		},
		methods: {
			loadMore() {
				this.loadStatus = "loading";
				setTimeout(() => {
					this.query.pageNo = parseInt(this.query.pageNo) + 1;
					this.loadList();
				}, 100);
			},
			search(value) {
				this.list = [];
				this.query.pageNo = 1;
				this.query.data = this.keywords;
				this.loadList();
			},
			loadList() {
				var _this = this;
				this.$u.api.box.findRdrThList(this.query).then(res =>{
					if(res.result != 'false' && res.data != undefined && res.data.length > 0){
						res.data.forEach(item => {
							_this.list.push(item);
						})
						this.loadStatus = "loadmore";
					}
					if(res.data == undefined || res.data.length > 0 && res.data.length < 10){
						this.loadStatus = "nomore";
					}
				})
			},
			navTo(url) {
				uni.navigateTo({
					url: url
				});
			}
		}
	}
</script>

<style>
@import '../btdm.css';
</style>
